ALTER PROCEDURE [dbo].[CPP_User_GameReport]
  @dwUserID INT,  -- 举报发起用户UserID
  @dwGameID INT,  -- 被举报用户GameID
  @szDesc NVARCHAR(128),  -- 举报内容
  @szResult NVARCHAR(255) OUTPUT  -- 输出信息
AS
BEGIN

  -- 用户提交举报
  
  DECLARE @Channel INT = 0
  SELECT @Channel = Channel FROM RYAccountsDB.dbo.AccountsInfo WHERE AccountsType = 0 AND UserID = @dwUserID
  IF @@ROWCOUNT=0 BEGIN
    SET @szResult = N'举报人[' + CAST(@dwUserID AS NVARCHAR) + ']不存在'
    RETURN 1
  END
  
  DECLARE @Channel2 INT = 0
  SELECT @Channel2 = Channel FROM RYAccountsDB.dbo.AccountsInfo WHERE AccountsType = 0 AND GameID = @dwGameID
  IF @@ROWCOUNT=0 BEGIN
    SET @szResult = N'被报人[' + CAST(@dwUserID AS NVARCHAR) + ']不存在'
    RETURN 2
  END
  
  IF @Channel<>@Channel2 BEGIN
    SET @szResult = N'举报人[' + CAST(@dwUserID AS NVARCHAR) + ']的渠道[' + CAST(@Channel AS NVARCHAR) + ']与被报人[' + CAST(@dwGameID AS NVARCHAR) + ']的渠道[' + CAST(@Channel2 AS NVARCHAR) + ']不一致'
    RETURN 3
  END
  
  DECLARE @dwLen INT = LEN(@szDesc)
  IF @dwLen=0 OR @dwLen>255 BEGIN
    SET @szResult = N'举报内容不能为空或超出长度255限制'
    RETURN 4
  END

  INSERT INTO [RYAccountsDB].[dbo].[RecordReporMessage] (
    [UserID], [GameID], [szMessage]
  ) VALUES (
    @dwUserID, @dwGameID, @szDesc
  );

  IF @@IDENTITY>0 BEGIN
    SET @szResult = N'SUCCESS'
    RETURN 0
  END ELSE BEGIN
    SET @szResult = N'FAILURE'
    RETURN 5
  END
  

END